package o2o.dao.PO.company.postman;

import lombok.Data;
import lombok.experimental.Accessors;
import o2o.cache.company.postman.PostTypeMemory;
import o2o.dao.VO.company.postman.ShopSignCompanyFeeVO;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 *  店铺与公司关系-不同配送类型的配送费信息
 *
 * @User: @Created by yangtk
 * @Date: @Date 2019/8/7 11:35
 * @Classname: ShopSignCompanyFeeInfo
 * @To change this template use File | Settings | File Templates.
 */
@Data
@Accessors(chain = true)
public class ShopSignCompanyFeeInfo implements Serializable {
    private Long id;
    private String sysAppKey;
    private Long companyId;
    private Long shopId;
    private int postType;
    private Double price = 0.0d;
    private Double companyShareRate;    //  配送公司分成比例
    private int delFlag = 0;
    private String createUser;
    private Long createTime;
    private String updateUser;
    private Long updateTime;

    @Override
    public int hashCode() {
        return this.getCompanyId().hashCode() * this.getShopId().hashCode() * this.getPostType();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof ShopSignCompanyFeeInfo) {
            ShopSignCompanyFeeInfo i2 = (ShopSignCompanyFeeInfo) obj;
            return i2.getCompanyId().equals(this.getCompanyId()) && i2.getShopId().equals(this.getShopId()) && i2.getPostType() == this.getPostType();
        }
        return super.equals(obj);
    }

    public ShopSignCompanyFeeVO convertToVo() {
        ShopSignCompanyFeeVO vo = new ShopSignCompanyFeeVO();
        BeanUtils.copyProperties(this, vo);
        PostTypeInfo info = PostTypeMemory.getInstance().getByCode(this.getPostType());
        vo.setPostTypeName(info == null ? "未知" : info.getName());

        return vo;
    }
}

